﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class OrderPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = (String)Session["TableID"];
        DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        DataTable dt = dv.Table;
        DataRowCollection drc = dt.Rows;
        int nbrOfDishes = drc.Count;
        foreach (DataRow r in drc)
        {
            //Current row in the table will hold info from current data row r
            TableRow tr = new TableRow();

            //Create a first cell in current row to hold the image
            TableCell c = new TableCell();
            Image img = new Image();
            img.ImageUrl = (String)r["Image"];
            img.AlternateText = ((String)r["Image"]) + " can't find it";
            //Add Image to cell
            c.Controls.Add(img);
            //Add cell to table
            tr.Cells.Add(c);

            //Create second cell in current row to hold description and Order to click
            TableCell c2 = new TableCell();
            String myLiteral = "<p>" + "Name: " + ((String)r["DishName"]) + "</br></br>";
            myLiteral = myLiteral + "Description: " + ((String)r["DishDescription"]) + "</br></br>";
            myLiteral = myLiteral + "Price: " + ((int)r["Price"]).ToString() + "</br>";
            myLiteral = myLiteral + "<a href=\"./ViewOrder.aspx?dish=" + ((String)r["DishName"]) + "\">Order</a> </p>";
            c2.Controls.Add(new LiteralControl(myLiteral));
            //new LiteralControl("<a href='./Images/dish1.png'>dish1</a>"));
            tr.Cells.Add(c2);

            Table1.Rows.Add(tr);
            Table1.Attributes.Add("Width", "750");
           // Table1.CssClass = "CSSTableGenerator";

        }

    }
}